home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / SocketClasses / SktSocketManager.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-23  |  5.9 KB  |  131 lines

  1. /***************************************************************************
  2. *                                                                          *
  3. * SktSocketManager.h                                                       *
  4. * Copyright 1992 by Nik A Gervae                                           *
  5. *                                                                          *
  6. * One of a set of three Objective-C classes (SktSocketManager, SktSocket,  *
  7. * and SktSocketUser) which implement a convenient interface to Berkeley    *
  8. * stream sockets under NeXTSTEP(r).  See the accompanying class            *
  9. * specifications (files with a .rtf or .spec suffix) for further           *
  10. * information.                                                             *
  11. *                                                                          *
  12. * NeXTSTEP is a registered trademark of NeXT Computer, Inc.                *
  13. *                                                                          *
  14. ****************************************************************************
  15. *                                                                          *
  16. * LICENSE                                                                  *
  17. *                                                                          *
  18. * This program is free software; you can redistribute it and/or modify     *
  19. * it under the terms of the GNU General Public License as published by     *
  20. * the Free Software Foundation.                                            *
  21. *                                                                          *
  22. * The program and this makefile are distributed in the hope that it will   *
  23. * be useful, but are provided "AS IS" AND WITHOUT ANY WARRANTY; without    *
  24. * any express or implied warranty of MERCHANTABILITY or FITNESS FOR A      *
  25. * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
  26. * Any use or distribution of the program and documentation must include    *
  27. * appropriate copyrights to acknowledge Nik A. Gervae and the Free         *
  28. * Software Foundation, Inc.                                                *
  29. *                                                                          *
  30. * You should have received a copy of the GNU General Public License        *
  31. * along with this program; if not, write to the Free Software              *
  32. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                *
  33. *                                                                          *
  34. ****************************************************************************
  35. *                                                                          *
  36. * VERSION HISTORY                                                          *
  37. *                                                                          *
  38. * Version numbers are simply dates in the form YYYYMMDD.  These represent  *
  39. * the date that version was finished.  Only significantly changed versions *
  40. * are reported here, or those versions requiring explanation of changes.   *
  41. * There may be many interim stages between dated versions.                 *
  42. *                                                                          *
  43. * DateVersion Primary Author  Notes                                        *
  44. * ----------- --------------- -------------------------------------------- *
  45. * 19920327    Nik A Gervae    First released version                       *
  46. * 19920723    Nik A Gervae    Actually released                            *
  47. *                                                                          *
  48. ***************************************************************************/
  49.  
  50. #import <stdio.h>
  51. #import <stdarg.h>
  52. #import <sys/time.h>
  53.  
  54. #ifdef NS3
  55. #import <objc/zone.h>
  56. #else
  57. #import <zone.h>
  58. #endif
  59.  
  60. #import <objc/Object.h>
  61. #import <objc/List.h>
  62.  
  63. #import "SktSocket.h"
  64.  
  65. @interface SktSocketManager : Object
  66. {
  67.   id      userClass;        // Class of all user instances
  68.  
  69.   FILE   *logfile;          // diagnostic output
  70.   char   *hostaddress;      // primary internet address of host in dot notation
  71.   char   *hostname;         // name of host program is running on
  72.   int     servicePort;      // internet port of program. Can TELNET to it.
  73.   int     numAvailFds;      // current amount of available file descriptors
  74.  
  75.   int     maxSocketFd;      // highest currently open fd--used by select()
  76.   int     serviceSocketFd;  // fd of the SktSocketManager object: connection
  77.                             //  requests made here
  78.   List   *openSockets;      // List object containing all open Socket objects
  79.  
  80.   BOOL    doesLog;          // YES if non-error messages logged
  81.  
  82.   NXZone *zone;             // All SktSockets & users are allocated from here
  83.  
  84.   struct timeval selectTimeout;     // how long -update waits to process i/o
  85.   BOOL           timeoutIndefinite; // if YES,  -update waits indefinitely
  86.   int            selectSignalMask;  // these are blocked during a select()
  87. }
  88.  
  89.  
  90. // Initializing
  91. - init;  // DON'T EVER SEND THIS
  92. - initPort:(int)portNum logfile:(FILE *)file fdCapacity:(int)cap
  93.     userClass:aClass;
  94. - setSocketOptions:(int)fd;
  95. - free;
  96. - setDoesLog:(BOOL)flag;
  97. - (BOOL)doesLog;
  98.  
  99. // "Advanced" Initializing (you need to know about the select() system call)
  100. - setTimeoutSeconds:(long int)secs microseconds:(long int)usecs;
  101. - (BOOL)getTimeoutSeconds:(long int *)secs microseconds:(long int *)usecs;
  102. - setTimeoutIndefinite;
  103. - (BOOL)isTimeoutIndefinite;
  104. - (int)setSignalMask:(int)sigmask;
  105. - (int)signalMask;
  106.  
  107. // Access
  108. - setFdCapacity:(int)cap;
  109. - (int)adjustFdCapacity:(int)byAmount;
  110. - (int)fdCapacity;
  111. - (int)numAvailFds;
  112.  
  113. - (FILE *)logfile;
  114. - (const char *)hostaddress;
  115. - (const char *)hostname;
  116. - (int)servicePort;
  117. - (char **)getInetAddresses;
  118.  
  119. // Getting work done
  120. - update;
  121.  
  122. // Operations on SktSocket Objects
  123. - closeSocket:(struct SktSocket *)socketObj;
  124. - closeAllSockets;
  125.  
  126. // Utility
  127. - announceString:(const char *)announcement;
  128. - log:(const char *)format, ...;
  129.  
  130. @end /*interface SktSocketManager*/
  131.